#include <QApplication>
#include <iostream>
#include <QMessageBox>
#include "eigen/eigen.h"
#include "win.h"

using namespace std;
//// Constants


    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
        UiDialog win;
        win.show();
        return app.exec();
    }


void UiDialog::showInformationDialog(QString post_mesage){
    
    QMessageBox::information(this,"Action Information",post_mesage);
}

void UiDialog::updateMesageBox(QString childMesage){
    
    if(!childMesage.isEmpty()){
        mesaj->append(childMesage);
        mesaj->update(); //do we need that ?
    }

}

void UiDialog::updateCropImage(){
    openImage("crop");
}

void UiDialog::updateFrameImage(){
    openImage("frame");
}

void UiDialog::openImage(QString img_name){
    
    QString real_image_name;

    if (img_name.compare("crop")==0)
        real_image_name = "tester/1_crop_1.pgm";
    else
        real_image_name = "lc.jpg";

    QImage image(real_image_name);
    
    if (!image.isNull()) {
    

    
    if (img_name.compare("crop")==0){
        crop->setPixmap(QPixmap::fromImage(image));
        crop->update();
    }
    else{
        frame->setPixmap(QPixmap::fromImage(image));
        frame->update();
    }
    }
}
void UiDialog::startVideoSurveilance(){
 
    if(startSurveilance){
    QString someWarn = "Program is already running sorry !";
    QMessageBox::information(this,"Runnig program",someWarn);
    }
    else{
        startSurveilance = true;
        //test_man(); // start the core stuff yoo ! *_*
        if (!my.isRunning())
            my.start();
    }
}

void UiDialog::stopVideoSurveilance(){
 
    if(!startSurveilance){
        QString someWarn = "Program is already stopped you can start it by Baslat!";
        QMessageBox::information(this,"Stopped Program",someWarn);
    }
    else{
        startSurveilance = false;
        emit stopProgram();
    }

    }


void UiDialog::startEigenLearn(){
    EigenLearn *el;
    el = new EigenLearn();el->learn("learn"); //FIXME hard coded
    delete el;
    el = 0;
    
    QString eigenDone = "Eigen training data computed succesfully !You can press Basla !";
    QMessageBox::information(this,"Eigen Done",eigenDone);
    }


